package com.lzw.breezeNovel.webApp.service.impl.common;

import com.lzw.breezeNovel.model.entity.pojo.Notice;
import com.lzw.breezeNovel.webApp.mapper.common.NoticeMapper;
import com.lzw.breezeNovel.webApp.service.common.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.service.impl.common
 * @date 2025/3/17
 * @description 通告的服务类
 */
@Service
@SuppressWarnings("all")
public class NoticeServiceImpl implements NoticeService {

    /**
     * 注入mapper
     */
    @Autowired
    private NoticeMapper noticeMapper;

    /**
     * 根据类型获取公告
     * @param type
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<String> getNoticeByType(Long type) {
        //获取通告信息
        List<Notice> notices = noticeMapper.selectNoticeByType(type);
        //获取通告内容
        return notices.stream().map(Notice::getContent).collect(Collectors.toList());
    }
}
